﻿using DataModels.Dto;
using DataModels.Dto.ShoppingMallDto;
using Microsoft.AspNetCore.Mvc;
using Services.ShoppingMall;
using Utils;
using static DataModels.Enums.GeneralEnum;

namespace PropertyManagementWebApi.Controllers.ShoppingMall
{
    public class ShoppingMallController(ShoppingMallService shoppingMallService) : BaseController
    {
        protected readonly ShoppingMallService _shoppingMallService = shoppingMallService;

        /// <summary>
        /// 获取分类列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetProductCategory()
        {
            return _shoppingMallService.GetProductCategory();
        }

        /// <summary>
        /// 获取商品列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResponseModel> GetProduct([FromQuery] GetProductInfo info)
        {
            return await _shoppingMallService.GetProduct(info);
        }

        /// <summary>
        /// 获取商品详情
        /// </summary>
        /// <param name="ProductUUID"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResponseModel> GetProductDetail([GeneralRequired] Guid ProductUUID)
        {
            return await _shoppingMallService.GetProductDetail(ProductUUID);
        }

        /// <summary>
        /// 提交订单
        /// </summary>
        /// <param name="infos"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResponseModel> SubmitOrder(List<ShoppingMallSubmitOrderInfo> infos)
        {
            return await _shoppingMallService.SubmitOrder(infos);
        }

        /// <summary>
        /// 订单付款
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResponseModel> OrderPayment(ShoppingMallOrderPaymentInfo info)
        {
            return await _shoppingMallService.OrderPayment(info.OrderUUID, PayWay.VX);
        }

        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetOrder([FromQuery] GetOrderInfo info)
        {
            return _shoppingMallService.GetOrder(info);
        }

        /// <summary>
        /// 获取商品已完成订单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetProductOrders([FromQuery] GetProductOrdersInfo info)
        {
            return _shoppingMallService.GetProductOrders(info);
        }

        /// <summary>
        /// 评论完成的订单
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResponseModel> SubmitOrderComment([FromBody] ShoppingMallSubmitOrderComment info)
        {
            return await _shoppingMallService.SubmitOrderComment(info);
        }

        /// <summary>
        /// 获取我的订单评论
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetOrderComment([FromQuery] GetOrderCommentInfo info)
        {
            return _shoppingMallService.GetOrderComment(info);
        }

    }
}
